home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Diamond Collection
/
The Diamond Collection (Software Vault)(Digital Impact).ISO
/
cdr44
/
spack100.zip
/
SUPPACK.DOC
< prev
next >
Wrap
Text File
|
1995-01-15
|
24KB
|
547 lines
Suppack version 1.00. Copyright (C) Christian Worm, 1995.
=================================================================
1. Table of contents
=================================================================
1. Table of contents
2. Introduction
2.1. What is Suppack?
2.2. Which files constitute the Suppack library?
2.3. How do I use Suppack?
2.4. Where can I find the latest version of Suppack?
2.5. How can I contact the author and how is the support?
3. Formal stuff
3.1. Copyright & distribution
3.2. Disclaimer
3.3. List of all files
4. How to use the C and C++ interfaces
4.1. Important notes
4.2. About the interface to standard C
4.3. About the interface to C++
5. How to use the Pascal interfaces
5.1. Important notes
5.2. About the interface to normal Pascal
5.3. About the interface to OOP-Pascal
6. About the source codes in general
6.1. Important notes
6.2. General structure of the source codes
6.3. It's all bad!
7. Information about the C++ source code
7.1. Important notes
7.2. Why use the C++ source code?
7.3. How to compile the C++ source code
7.4. What prior work is the suppack derived from?
7.5. On the tables used by the static huffman part
8. Information about the Assembler source code
8.1. Important notes
8.2. How to assemble the library
8.3. How to assemble to the C/C++ interface
8.4. How to assemble to the Pascal interface
8.5. About the structure of the library
8.6. Organization of data in the work space
8.7. Some techinfo on the library
9. History
10. Credit
=================================================================
2. Introduction
=================================================================
2.1. What is Suppack?
-----------------------------------------------------------------
Suppack is a library which can be used for general packing and
extraction of data. The user has 100% control over input and
output, hence it should be usable in just about all cases where
packing is required.
As compiled the library requires at least an 80286 processor, but
full source code is included and it is possible to recompile the
library to support 8086/8088. Please note that new versions of
this library might use another format for the packed data than
this one does.
2.2. Which files constitute the Suppack library?
-----------------------------------------------------------------
The files of the Suppack library don't all float around in the
same directory; they are grouped into subdirectories. If you have
received the file SPACK100.ARJ, please remember to unpack it with
the -x switch (arj -x spack100), this tells the archiver to put
the suppack files into the subdirectories where they belong.
When you have installed Suppack in a directory it should contain
the following subdirectories:
CINTF C and C++ interface to the library.
PASINT Pascal interface, both OOP and ordinary Pascal version.
CPPSOUR C++ source for the library.
ASMSOUR Assembler source code for the library.
You will only need the files in CPPSOUR and ASMSOUR if you want
to understand how the packer/unpacker works under the hood and/or
want to make changes to the library.
Apart from the abovementioned subdirectories, you should see the
following files:
FILE_ID.DIZ Description of the library.
SUPPACK.DOC This file.
SUPPACK.EXE Compiled example of a program which uses the
library.
For a complete list of what the subdirectories contain, see
section 3.3. For a description of the subdirectories in ASMSOUR,
see section 8.5.
2.3. How do I use Suppack?
-----------------------------------------------------------------
Suppack supports the following Intel real mode platforms "out-of-
the-box":
1) C
2) C++
3) Turbo Pascal
4) Turbo Pascal OOP
It should also be possible to use the library together with any
other serious programming language but I'm not able to give a
general guide on how to do it.
Interfaces to C(++) and Pascal are put in two different director-
ies, please refer to section 4 and section 5 for details on these
interfaces. It should be noted that all interfaces contain one or
more EXAMPLE*.* files. These are all examples of approximately
the same simple program which can be used as a general file
packer. A compiled version of one of these programmes is included
as the file SUPPACK.EXE. Overall, the library works by calling a
routine for doing the packing or unpacking. In the structured
interfaces this routine must be passed a pointer to a memory area
the library can use and pointers to call-back functions which
must read and write the packed and unpacked data. In the object
oriented languages the interface is an object/a class with
virtual methods for reading and writing data.
2.4. Where can I find the latest version of Suppack?
-----------------------------------------------------------------
The library is available from NightCall BBS aka 2:237/10@fido-
net.org and 2:237/11@fidonet.org. Filerequest SUPPACK for the
latest version.
2.5. How can I contact the author and how is the support?
-----------------------------------------------------------------
As this library is free I cannot guarantee any form of support
for it. I will presumably answer all questions sent as e-mail and
all questions with an enclosed stamped self-addressed envelope
which can be sent from Denmark. But I cannot make any promises.
As to questions and general comments, such as information on bugs
in the packer and bugs in the source code, I can currently be
reached under the name Christian Worm Mortensen at the address
2:237/10.7@fidonet.org. My snail mail address which all informa-
tion on the actual inclusion of this library in programs are to
be sent to (q.v. section 3.1) is:
Christian Worm
Ledavej 80
9210 Aalborg SO
Denmark
=================================================================
3. Formal stuff
=================================================================
3.1. Copyright & distribution
-----------------------------------------------------------------
The library has been written by Christian Worm who has the full
copyright. With the exception of the C++ source code (see section
7.4 for details) it can be freely used but under the condition
that information are sent to me as to which programs it is used
in. See section 2.5 for address. The library can be freely
distributed as long it is not modified. See section 3.3 for a
list of all the files the library contains. It is not allowed to
distribute any part of the source code in any modified form
without written permission from the author. If you have made /
consider making changes and feel that others may benefit from
them, please send me a note.
3.2. Disclaimer
-----------------------------------------------------------------
The author makes no warranties, either expressed or implied, with
respect to the material described herein. Should the library
prove defective, the user (and not the author), assumes the
entire cost of all damages. In no event will the author be liable
for direct, indirect, incidental or consequential damages
resulting from any defect in the program.
Other people's work has been used in order to create this
library. Although I certainly do feel I have created this library
myself and that I have the sole right to set the conditions for
use of this library, a judge might think otherwise. Therefore,
the conditions set forth by Yoshizaki that the source to his
program LZHUF (please refer to 7.4 and 8.1) may not be used
commercially may apply to this library, too. If they do, I cannot
take any responsible for that, either.
3.3. List of all files
-----------------------------------------------------------------
The following is a complete of all the files included in the
library and the subdirectories they are placed in.
FILE_ID.DIZ
SUPPACK.DOC
SUPPACK.EXE
CINTF\CPPPACK.CPP
CINTF\CPPUNP.CPP
CINTF\EXAMPLE2.CPP
CINTF\EXAMPLE3.CPP
CINTF\EXAMPLE4.C
CINTF\SUPPACK.H
CINTF\SUPPACK.HPP
CINTF\SUPPACK.LIB
PASINTF\EXAMPLE5.PAS
PASINTF\EXAMPLE6.PAS
PASINTF\PASCOMN.OBJ
PASINTF\PASDECOD.OBJ
PASINTF\PASENCOD.OBJ
PASINTF\SUPOPACK.PAS
PASINTF\SUPPACK.PAS
CPPSOUR\EXAMPLE1.CPP
CPPSOUR\HUFFMAN.CPP
CPPSOUR\HUFFMAN.HPP
CPPSOUR\MAKETABL.CPP
CPPSOUR\PACK.CPP
CPPSOUR\PACK.HPP
CPPSOUR\PACKINT.HPP
CPPSOUR\PACKTABL.HPP
CPPSOUR\UNPACK.CPP
CPPSOUR\UNPACK.HPP
CPPSOUR\UNPTABL.HPP
ASMSOUR\PASCOMP.CPP
ASMSOUR\PASCOMP.EXE
ASMSOUR\TASM.CFG
ASMSOUR\BUFFERIO\BUFBITRD.AH
ASMSOUR\BUFFERIO\BUFBITRD.ASM
ASMSOUR\BUFFERIO\BUFBITWR.AH
ASMSOUR\BUFFERIO\BUFBITWR.ASM
ASMSOUR\BUFFERIO\BUFBYTRD.AH
ASMSOUR\BUFFERIO\BUFBYTRD.ASM
ASMSOUR\CTRL\DECODE.AH
ASMSOUR\CTRL\DECODE.ASM
ASMSOUR\CTRL\ENCODE.AH
ASMSOUR\CTRL\ENCODE.ASM
ASMSOUR\CTRL\PACKGEN.AH
ASMSOUR\CTRL\PACKINT.AH
ASMSOUR\CTRL\UNPKINT.AH
ASMSOUR\DHUFFMAN\HUFFGEN.ASM
ASMSOUR\DHUFFMAN\HUFFMAN.AH
ASMSOUR\DHUFFMAN\HUFFPACK.ASM
ASMSOUR\DHUFFMAN\HUFFUNPK.ASM
ASMSOUR\HIGHINTF\HINTFGEN.AH
ASMSOUR\HIGHINTF\HINTFGEN.ASM
ASMSOUR\HIGHINTF\HINTFINT.AH
ASMSOUR\HIGHINTF\HINTFPAC.ASM
ASMSOUR\HIGHINTF\HINTFUNP.ASM
ASMSOUR\LZSS\LZSSGEN.AH
ASMSOUR\LZSS\LZSSPACK.AH
ASMSOUR\LZSS\LZSSPACK.ASM
ASMSOUR\LZSS\LZSSUNPK.AH
ASMSOUR\LZSS\LZSSUNPK.ASM
ASMSOUR\SHUFFMAN\PACKTABL.AH
ASMSOUR\SHUFFMAN\PACKTABL.ASM
ASMSOUR\SHUFFMAN\UNPTABL.AH
ASMSOUR\SHUFFMAN\UNPTABL.ASM
=================================================================
4. How to use the C and C++ interfaces
=================================================================
4.1. Important notes
-----------------------------------------------------------------
Note: You should read section 2.3 before continuing with this
section.
Note: The C and C++ interfaces can be found the subdirectory
named CINTF (q.v. section 2.2).
Note: The code has been written and tested with Borland C++ 4.02
but should work with other compilers.
Note: Unless you are an experienced programmer you will probably
only be able to make the packer work in the large, compact and
maybe huge memory models.
4.2. About the interface to standard C
-----------------------------------------------------------------
In order to use the Suppack library in a C program the file
SUPPACK.LIB must be linked with your program. At the same time
the file SUPPACK.H must be included in the modules which the
packer are to be used in. Four routines are provided - see
SUPPACK.H for an explanation of these and EXAMPLE4.C for an
example of how to use them.
4.3. About the interface to C++
-----------------------------------------------------------------
Note: The C interface can be used directly in a C++ program if
this is desired. One can also use the special C++ interface: It
requires you to link SUPPACK.LIB and one or two of the files
CPPPACK.CPP and CPPUNP.CPP with you program. Depending if you
want to pack, unpack or both. The modules using the interface
should include SUPPACK.HPP - refer to it for closer information
on the usage. EXAMPLE2.CPP and EXAMPLE3.CPP are two different
example programs which do more or less the same thing.
EXAMPL2.CPP uses C++ streams whereas EXAMPLE3.CPP uses Borland/MS
file function calls for file I/O.
=================================================================
5. How to use the Pascal interfaces
=================================================================
5.1. Important notes
-----------------------------------------------------------------
Note: You should read section 2.3 before continuing with this
section.
Note: The Pascal and Pascal OOP interfaces can be found the
subdirectory named PASINTF (q.v. section 2.2).
Note: The code has been written and tested with Turbo Pascal 6.0
but should work with other compilers.
5.2. About the interface to normal Pascal
-----------------------------------------------------------------
In order to use the Suppack library in a non-object oriented
Pascal program one has to use the unit SUPPACK.PAS which handles
all the interfacing to the assembler packing routines. Note that
Turbo Pascal also must be able to find the 3 files PASCOMN.OBJ,
PASDECOD.OBJ, and PASENCOD.OBJ during compilation. See
EXAMPLE5.PAS for an example of how the unit can be used.
5.3. About the interface to OOP-Pascal
-----------------------------------------------------------------
In order to use the Suppack library in an OOP Pascal program one
can use the unit SUPOPACK.PAS which uses the unit SUPPACK.PAS to
interface to the assembler modules (the two units can relatively
easy be combined to one). See EXAMPLE6.PAS for an example of how
the unit can be used.
=================================================================
6. About the source codes in general
=================================================================
6.1. Important notes
-----------------------------------------------------------------
The following sections are about the source code for the library.
It is not necessary to know / use the source code in order to
include the packing routines in one's own programs.
Both C++ and assembler source to the library is included, in the
directories CPPSOUR and ASMSOUR, respectively. See section 7 and
8 for details.
6.2. General structure of the source codes
-----------------------------------------------------------------
I have put the most general comments on the various source files
in their related header file. A file with the extension AH is an
assembly header, one with the extension HPP is a C++ header, and
one with the extension H is a C header. A header file which name
ends in INT is an "internal" header file - i.e. one which is used
by a limited number of modules. A file with the ending GEN is a
general header file - i.e. one which is used by many different
modules and doesn't have a specific source file connected to it.
There is no clear distinction between these two types.
6.3. It's all bad!
-----------------------------------------------------------------
There are surely loads of errors in the comments, especially for
the assembler code - I haven't checked them.
I am fully aware that the code is not commented perfectly and I
considered not releasing the source. So if you want to nag please
have in mind that the alternative to this mess would have been
that no source code were released. Remember that I have not
earned a single penny on this packer! Nevertheless, I would like
to hear concrete suggestions for changes to the comments.
=================================================================
7. Information about the C++ source code
=================================================================
7.1. Important notes
-----------------------------------------------------------------
Note: You should read section 6 before continuing with this
section.
Note: The C++ source code can be found the subdirectory named
CPPSOUR (q.v. section 2.2).
Note: PACKINT.HPP contains a general description of the packers
working method.
7.2. Why use the C++ source code?
-----------------------------------------------------------------
The C++ version of the library has the "benefit" of being more
cumbersome to use than the assembler version, take up more space,
be _a_lot_ slower, and it has a limitation which makes it unable
to handle error reports from the user's own I/O routines. The
reason for it being included despite all this is that if one
tries to look under the hood of the packer it is a lot easier to
understand than the assembler version which isn't as richly
commented. This code is only meant to be an aid in understanding
the workings of the packer and the assembler source code.
7.3. How to compile the C++ source code
-----------------------------------------------------------------
The classes which makes up the interface to the user are not 100%
compatible with those which are in the C++ interface to the
assembler packer - see EXAMPLE1.CPP for information on how they
work. To test the source code all the compiled .CPP files except
for the file MAKETABL.CPP are to be linked together.
Please note that the source code has been written for and tested
with Borland C++ 4.02. I cannot guarantee that it will work with
other compilers and I would like to hear about problems (not
including problems with BC++ 3.0 which is so bugridden that I
don't have any ambitions of making the packer work under it).
7.4. What prior work is the suppack derived from?
-----------------------------------------------------------------
In case anyone wants more information I can inform that the
source code has been built around LZHUF which is written by
Haruyasu Yoshizaki. LZHUF is released together with two other
packers, namely LZSS, LZARI together with an article describing
how the packers work in general.
Please note that some parts of the C++ packer has been copied
verbatim from LZHUF and that it is not allowed to use LZHUF for
commercial purposes. Hence, it is not allowed to use the C++
packer for commercial purposes - which, to be honest, probably
would be a hindrance.
7.5. On the tables used by the static huffman part
-----------------------------------------------------------------
The program MAKETABL.CPP is used to create the table used by the
static huffman compression used in both the packer as well as the
unpacker. These tables are put in the two header files
PACKTABL.HPP and UNPTABL.HPP. The tables are also used by the
assembler library and you have to convert them to assembler
source code by hand if you make changes.
=================================================================
8. Information about the Assembler source code
=================================================================
8.1. Important notes
-----------------------------------------------------------------
Note: You should read section 6 before continuing with this
section.
Note: The directory ASMSOUR contains assembler routines which are
translated from the routines in the CPPSOUR directory (see
section 7). Even though they resemble each other in structure,
this is not a case of line by line translation. There are certain
differences.
Note: You should refer to CTRL\PACKGEN.AH for information on how
the library can be reassembled to support 8086/8088.
8.2. How to assemble the library
-----------------------------------------------------------------
The source is written for TASM MASM mode, I cannot guarantee that
it will work if assembled with MASM and would like to hear about
any trouble.
The library should be assembled in different ways depending on
whether it is to be used with C/C++ or Pascal. Note that the
C/C++ interface in principle also can use the assembled Pascal
library.
8.3. How to assemble to the C/C++ interface
-----------------------------------------------------------------
The library can be created by assembling all .ASM files and
putting the OBJ files into the SUPPACK.LIB library which is used
by the C/C++ interface.
8.4. How to assemble to the Pascal interface
-----------------------------------------------------------------
The program PASCOMP.EXE with source code in PASCOMP.CPP (sorry
that the source is not in Pascal - that language is not where I
show my excellence), merges all the assembler files into three
new assembler files which must be assembled to OBJ format. It is
these three files that the Pascal interface uses. It is split
into three files to ensure that a program which uses only the
packer or uses only the unpacker doesn't link in any extraneous
code.
8.5. About the structure of the library
-----------------------------------------------------------------
Note: You should refer to the C++ source code for information on
how the packing/unpacking works. The various directories stored
in the ASMSOUR subdirectory are:
LZSS This directory contains routines for LZSS packing and
unpacking. However, the LZSS packing is partially done
by ENCODE.ASM elsewhere.
DHUFFMAN This directory contains all routines to be used with
dynamic huffman packing and unpacking.
SHUFFMAN This directory contains tables used with static huffman.
The tables are made by MAKETABL.CPP in the C++ source
code (q.v. section 7.5).
BUFFERIO This is the place for the following modules all working
with buffers:
1) A module which can read bit by bit and which gets its
data from the function user_read (see below).
2) A module which can write bit by bit and which writes
itself by calling user_write (see below)
3) A module which can read byte by byte and which gets
data from user_read.
There is no module for writing byte by byte since this
is included in the LZSS unpacker part.
CTRL Here is the packing/unpacking routines which controls
the other modules. This directory also contains some
header files which configure the packer and its memory
usage and which is included by all files (see below).
HIGHINTF The modules in this directory create the interface to
high level languages. This is done by, amongst other
things, supporting parameters passed on the stack and by
setting up ES and DS to point at the data areas which
the packer uses and by clearing the direction flag. It
is also done by declaring user_read and user_write and
passing calls to these on to the user.
8.6. Organization of data in the work space
-----------------------------------------------------------------
The routines should be given some work space by the user and the
space is organized in the following way: The various modules
declare a struc with the name *_mem containing the data they
need. CTRL\PACKGEN.AH defines macros for defining these data in
this segment. These definitions are performed in the following
files:
CTRL\PACKGEN.AH: Declares strucs common to packer and unpacker
CTRL\UNPKINT.AH: Declares strucs particular to unpacker
CTRL\PACKINT.AH: Declares strucs particular to packer
8.7. Some techinfo on the library
-----------------------------------------------------------------
The registers BP, SI, DI, DS, and ES are saved at every call to
the packer but only DS will be preserved for the call-back
routines. The routines reset the direction flag and always
deliver it reset. All code is put in the segment PACK_TEXT. The
routines should be 100% reentrant although I haven't tested it.
=================================================================
9. History
=================================================================
Version News
0.90a First version, with restrictions on distribution.
1.0 1) EXAMPLE files and documentaion translated into
english.
2) The different DOC files joined to one.
3) Minor changes to the highlevel language interfaces.
=================================================================
10. Credit
=================================================================
Thanks to SUne Trudslev (2:236/174.17@fidonet.org) for making a
translation of all manuals into English.
Thanks to Peter Finderup Lund (2:234/99.16@fidonet.org and
firefly@hib.ruc.dk), also for making a translation of all manuals
into English.
The main parts of the manuals are based on PFL's edition. The
places where there are grammar errors are probably the places
where I have written something myself :-)
Thanks to SUne Trudslev for translating all the non-documentation
material into English.
Thanks to Peter Finderup Lund for writing a draft for the Pascal
interface.